package Gather.CollectionsDome;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

/**
 * ClassName:Collections003
 * Package:Gather.CollectionsDome
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/21-20:10
 * @Version:v1.0
 */
public class Collections003 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, 1, 2, 3, 4, 5, 6, 7, 8, 9);
        System.out.println(list);
        //public static <T> void sort(List<T> list) 排序
        //public static <T> void sort(List<T>list , Comparator<T> c) 根据指定的规则进行排序
        System.out.println("------sort自己指定排序规则------");
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        System.out.println(list);


    }
}
